<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php

class Download extends CI_Controller
{

	 public function __construct()
    {
        parent::__construct();
		
		$this->load->helper('url');
	}
	
	
	function index() 
	{	
		$this->downloadacadinfo();
	}


	function downloadacadinfo($stdno)
	{
		$this->load->library('cezpdf');
		
		$this->cezpdf->ezText("Institute of Computer Science", 30, array('justification' => 'center'));
		$this->cezpdf->ezSetDy(-20);
		$this->cezpdf->ezText("Student's Academic Information", 16, array('justification' => 'center'));
		$this->cezpdf->ezSetDy(-30);

		$this->load->model('student_model');
		$result = $this->student_model->studAcadInfo($stdno);
		
		/* Name */
		$content = '                        Name:                                      ' . $result["name"];
		$this->cezpdf->ezText($content, 11);
		$this->cezpdf->ezSetDy(-3);
		
		/* Student Number */
		$content = '                        Student Number:                     ' . $stdno;
		$this->cezpdf->ezText($content, 11);
		$this->cezpdf->ezSetDy(-3);
		
		/* Advisers */
		if($result["reg_adviser"] != NULL){
			$content = '                        Registration Adviser:               ' . $result["reg_adviser"];
			$this->cezpdf->ezText($content, 11);
			$this->cezpdf->ezSetDy(-3);
		}
		
		if($result["sp_adviser"] != NULL){
			$content = '                        Current SP Adviser:                ' . $result["sp_adviser"];
			$this->cezpdf->ezText($content, 11);
			$this->cezpdf->ezSetDy(-3);
		}
		
		/* Curriculum */
		if($result["curriculum"] != NULL){
			$content = '                        Curriculum:                              ' . $result["curriculum"];
			$this->cezpdf->ezText($content, 11);
			$this->cezpdf->ezSetDy(-3);
		}
		
		/* Approved GE */
		if($result["approved_ge"] != NULL){
			$content = '                        Approved GEs:  ';
			$this->cezpdf->ezText($content, 11);
			$this->cezpdf->ezSetDy(-3);
			foreach($result["approved_ge"] as $item){
				$this->cezpdf->ezText('                                                                        ' . $item, 11);
				$this->cezpdf->ezSetDy(-2);
			}
		}
		
		/* Approved Electives*/
		if($result["approved_electives"] != NULL){
			$content = '                        Approved Electives: ';
			$this->cezpdf->ezText($content, 11);
			$this->cezpdf->ezSetDy(-3);
			foreach($result["approved_electives"] as $item){
				$this->cezpdf->ezText('                                                                        ' . $item, 11);
				$this->cezpdf->ezSetDy(-2);
			}
		}
		
		/* Subjects Taken*/
		if($result["subjects_taken"] != NULL){
			$this->cezpdf->ezSetDy(-25);
			foreach($result["subjects_taken"] as $item){
				$subj_taken[] = array(
					'cnum' => $item['course_no_fk'],
					'units' => $item['units'],
					'grade' => $item['grade'],
					'sem' => $item['sem'],
					'year' => $item['year'],
					'type' => $item['type'],
				);
			}
			
			$col_names = array(
				'cnum' => 'Course Number',
				'units' => 'Units',
				'grade' => 'Grade',
				'sem' => 'Semester',
				'year' => 'Year',
				'type' => 'Type',
			);
		
			$this->cezpdf->ezTable($subj_taken, $col_names, 'Subjects Taken', array('width'=>460));
		}
		
		/* Academic History */
		if($result["academic_history"] != NULL){
			$this->cezpdf->ezSetDy(-25);
			foreach($result["academic_history"] as $item){
				$acad_hist[] = array(
					'sem' => $item['sem'],
					'year' => $item['year'],
					'gwa' => $item['gwa'],
					'standing' => $item['standing'],
				);
			}
			
			$col_names = array(
				'sem' => 'Semester',
				'year' => 'Year',
				'gwa' => 'GWA',
				'standing' => 'Standing',
			);
		
			$this->cezpdf->ezTable($acad_hist, $col_names, 'Academic History', array('width'=>460));
		}
		
		/* Cases Involved */
		if($result["cases"] != NULL){
			$this->cezpdf->ezSetDy(-25);
			foreach($result["cases"] as $item){
				$cases[] = array(
					'case' => $item['case_description'],
					'date' => $item['date'],
				);
			}
			
			$col_names = array(
				'case' => 'Case Description',
				'date' => 'Date',
			);
		
			$this->cezpdf->ezTable($cases, $col_names, 'University Cases Involved', array('width'=>460));
		}
		
		$this->cezpdf->ezStream();
	}
}

?>